package org.box.metadata.shell.web;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class WebConsoleCallback {
	
	public WebConsoleCallback(Collection<LogRecord> buffer, int lastIndex, String sessionId, boolean busy) {
		this.consoleBusy = busy;
		
		records = new ArrayList<LogRecord>();
		for (LogRecord r : buffer) {
			if (r.getIndex() > lastIndex && 
					(r.getSession() == null || r.getSession().equals(sessionId)))
				records.add(r);
		}
	}

	private final boolean consoleBusy;
	private final List<LogRecord> records;

	public List<LogRecord> getRecords() {
		return records;
	}

	public boolean isConsoleBusy() {
		return consoleBusy;
	}

}
